<template>
    <div>
        <div v-for="item in orders" style="margin: 10px;border-radius: 5px;background-color: #fff;padding: 15px 0;">
            <div class="container-fluid">
                <div class="row" style="margin-bottom: 15px;position: relative">
                    <div class="col-xs-6">订单号：{{item.order_no}}</div>
                    <div class="col-xs-6">
                        <span v-if="item.agent_receipt_confirm == 0"
                              style="position: absolute;right: 0;background-color: rgb(238, 238, 238);border-radius: 12px 0 0 12px;line-height: 24px;padding-left: 16px;">状态:待卖家收款</span>
                        <span v-if="item.agent_receipt_confirm == 1"
                              style="position: absolute;right: 0;background-color: rgb(238, 238, 238);border-radius: 12px 0 0 12px;line-height: 24px;padding-left: 16px;">状态:卖家已收款</span>
                    </div>
                </div>
                <div class="row" style="margin-bottom: 15px;">
                    <div class="col-xs-6">
                        <img style="width: 100%;" :src="item.collection_image">
                    </div>
                    <div class="col-xs-6" style="text-align: right;">
                        <p style="color: gray">时间:{{item.order_time}}</p>
                        <p style="color: rgb(214, 111, 84);"><span class="label label-warning"
                                                                   style="margin-right: 5px;">字画墨宝</span>{{item.collection_name}}
                        </p>
                        <p><span style="color: rgb(214, 111, 84);font-weight: bold;font-size: 16px;">￥{{item.order_price}}</span>
                        </p>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <!--                        <p style="font-weight: bold;font-size: 16px;">待卖家确认付款</p>-->
<!--                        <button-->
<!--                            v-if="item.is_complaint == 0"-->
<!--                            @click="postComplaint(item.id, 'y')"-->
<!--                            style="width: 50%;border: none;background-color: rgb(214, 111, 84);color: #fff;text-align: center;border-radius: 5px;line-height: 30px;">-->
<!--                            投诉订单-->
<!--                        </button>-->
                    </div>
                    <div class="col-xs-6" style="text-align: right">
                        <!--                        todo-->
                        <button
                            v-if="item.is_complaint == 1"
                            @click="postComplaint(item, 'n')"
                            style="border: none;background-color: rgb(214, 111, 84);color: #fff;text-align: center;border-radius: 5px;line-height: 30px;">
                            取消投诉
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    import swal from "sweetalert";

    export default {
        name: 'TabOrderComplaint',
        data() {
            return {
                orders: [
                    // {
                    //     // id: '',
                    //     // order_price: '',
                    //     // order_time: '',
                    //     // order_no: '',
                    //     // agent_name: '',
                    //     // agent_contract: '',
                    //     // collection_name: '',
                    //     // collection_status_text: '',
                    //     // order_status: '',
                    // }
                ]
            }
        },
        created() {
        },
        mounted() {
            this.getOrders();
        },
        methods: {
            getOrders() {
                let that = this;
                this.api.getOrders(3).then(res => {
                    if (res.data) {
                        that.orders = res.data;
                    }
                })
            },
            postComplaint(item, action) {
                swal({
                    title: "温馨提示",
                    text: "是否确认投诉？",
                    // icon: "warning",
                    buttons: ["取消", "确认"],
                    dangerMode: true,
                }).then((f) => {
                    if (f) {
                        let that = this;
                        let wx_openid = localStorage.getItem('wx_openid');
                        this.api.postComplaint(wx_openid, item.id, action).then(res => {
                            if (res.meta.code == '000') {
                                swal('操作成功');
                                window.location.reload();
                            }
                        })
                    }
                });
            }
        },
    }
</script>
<style scoped>


</style>
